<link rel="stylesheet" type="text/css" href="<?php echo TEMPLATES_PATH;?>/css/login.css?v=<?php echo VERSION;?>">
<script type="text/javascript" src="<?php echo RESOURCE_PATH;?>/js/jquery.validation.min.js?v=<?php echo VERSION;?>"></script>
<script type="text/javascript" src="<?php echo RESOURCE_PATH;?>/js/jquery.metadata.js?v=<?php echo VERSION;?>" charset="utf-8"></script>
<script type="text/javascript" src="<?php echo TEMPLATES_PATH;?>/js/area_array.js?v=<?php echo VERSION;?>" charset="utf-8"></script>
<script type="text/javascript" src="<?php echo TEMPLATES_PATH;?>/js/common_select.js?v=<?php echo VERSION;?>" charset="utf-8"></script>
<style type="text/css">
#region select{ width:100%; height:34px; font-size:14px; font-family:"微软雅黑"; border-color:#CCC;}
    #invite_yes,#invite_no{border:1px solid red;color:rgb(247, 38, 38);font-size:.8em;font-weight:normal;padding: 0.5em 0.8em;border-radius:5px;margin:20px;}
    .insidetip a{text-decoration: underline;color:rgb(247, 38, 38)}
</style>
<header>
    <div class="new-header">
    	<a href="javascript:back(true);" class="new-a-back"><span>返回</span></a>
    	<h2>会员注册</h2>
    	<a href="javascript:void(0);" id="btnJdkey" class="new-a-jd"><span>美财键</span></a>
    </div>
	<?php require_once 'fast_key.php';?>
</header>
<div id="mainLayout" style="display:-webkit-box;">
    <div class="new-ct" id="mainStay" style="-webkit-box-flex: 1;width: 100%;">
        <div class="new-ct bind">
        <div class="new-pay-pw">
            <div class="new-set-info">
                <form action="#" method="post" id="login_form" enctype="multipart/form-data">
                    <input type="hidden" name="form_submit" value="ok" />
                    <input name="nchash" type="hidden" value="<?php echo $output['nchash'];?>" /> 
                    <span class="new-input-span mg-b15">
                        <input type="text" value="" class="new-input" name="regName" id="regName" placeholder="用户名" maxlength="20" />
                    </span>
                    <span class="new-input-span mg-b15">
                        <input type="password" value="" class="new-input" name="pwd" id="pwd" placeholder="设置密码" maxlength="20">
                    </span>
                    <span class="new-input-span mg-b15">
                        <input type="password" value="" class="new-input" name="pwdRepeat" id="pwdRepeat" placeholder="确认密码" maxlength="20">
                    </span>
                    <?php if(true||C('captcha_status_register') == '1') { ?>
                        <span class="new-input-span mg-b15">
                        <input type="text" value="" class="new-input" name="captcha" id="captcha" placeholder="验证码" maxlength="4">
                    </span>
                        <div style="margin-bottom:10px; height:40px;">
                        <img src="index.php?act=seccode&op=makecode&nchash=<?php echo $output['nchash'];?>" name="codeimage" border="0" id="codeimage" style="float:left;" />
                        <a href="javascript:void(0)" onclick="javascript:document.getElementById('codeimage').src='index.php?act=seccode&op=makecode&nchash=<?php echo $output['nchash'];?>&t=' + Math.random();" style="display:block; float:left; line-height:40px; margin-left:5px; background:#F90; color:#FFF; border-radius:5px; padding:0 15px;">看不清，换一张</a>
                        </div><?php }?>
                    <span class="new-input-span mg-b15">
                        <input type="text" value="" class="new-input" name="mobile" id="mobile" placeholder="手机号码">
                    </span>
                    <span class="new-input-span mg-b15">
                        <input onClick="sendMobileCode()" type="button"  class="btn" id="dyMobileButton" value="获取短信验证码" />
                        <input type="text" value="" class="new-input" name="mobileCode" id="mobileCode" placeholder="短信验证码" />
                    </span>
         
                    <span class="new-input-span mg-b15" id="invite_member">
                        <input type="text" value="" class="new-input" name="invite_name" id="invite_name" placeholder="邀请会员" maxlength="21" style="margin-bottom:15px;" />
                        <span id="invite_no">没有邀请会员？</span>
                    </span>
                    <input type="hidden" name="mv_type" id="mv_type" value="invite_name" />
                    <span id="invite_member_no">
                        <span id="invite_yes">已有邀请会员</span>
                    <span class="new-input-span mg-b15">
                        身份证正面照：
                        <input type="file" class="file_upload" name="member_idcard" id="member_idcard" />
                    </span>
                     <span class="new-input-span mg-b15">
                        身份证反面照：
                        <input type="file" class="file_upload" name="member_idcard_r" id="member_idcard_r" />
                    </span>
                    <span class="new-input-span mg-b15">
                        店内照片：
                        <input type="file" class="file_upload" name="member_inside_photo" id="member_inside_photo" />
                       <b class="insidetip"> 店内照片注意：请上传本人手持身份证照片，站在吧台内，确保身份证号码清晰：<a href ="<?php echo SiteUrl.'/upload/login/3_conew1.jpg'?>">图片示例</a>
                       </b>
                    </span>
                        </span>
                    <!--<span class="new-input-span mg-b15">
                        所在部门：
                        <input id="boss" name="department" value="<?php /*echo MEMBER_POSITION_BOSS;*/?>" type="radio" checked="checked">
                        <label class="pad" for="boss">老板</label>
                        &nbsp;&nbsp;
                        <input id="not_boss" name="department" value="<?php /*echo MEMBER_POSITION_CLERK;*/?>" type="radio">
                        <label class="pad" for="not_boss">店员</label>
                    </span>
                    <span class="new-input-span mg-b15">
                        所属行业：
                        <input id="purpose1" name="purposetype" value="<?php /*echo MEMBER_INDUSTRY_MR;*/?>" type="radio" checked="checked">
                        <label class="pad" for="purpose1">美容</label>&nbsp;
                        <input id="purpose2" name="purposetype" value="<?php /*echo MEMBER_INDUSTRY_MF;*/?>" type="radio">
                        <label class="pad" for="purpose2">美甲</label>&nbsp;
                        <input id="purpose3" name="purposetype" value="<?php /*echo MEMBER_INDUSTRY_MJ;*/?>" type="radio">
                        <label class="pad" for="purpose3">美发</label>&nbsp;
                        <input id="purpose4" name="purposetype" value="<?php /*echo MEMBER_INDUSTRY_YZ;*/?>" type="radio">
                        <label class="pad" for="purpose4">沐足</label>
                    </span>
                    <span class="new-input-span mg-b15">
                        <input type="text" value="" class="new-input" name="companyname" id="companyname" placeholder="店名" maxlength="51">
                    </span>
                    <span class="new-input-span mg-b15"  id="region">
                        <em style=" display:block; width:100%;color:#F00; font-size:14px; text-align:center">&lowast;商城所在地注册成功后不可更改，请您认真选择&lowast;</em>
                        <select name="province_id" id="province_id" class="{required:true,messages:{required:'请选择省份'}}"></select>
                    </span>
                    <span class="new-input-span mg-b15">
                        <input type="text" value="" class="new-input" name="companyaddr" id="companyaddr" placeholder="商城详细地址" maxlength="101">
                    </span>


               <div id="default_hide" style="position:relative;">

                   <div id="back_bizlicense">
                       已有营业执照
                   </div>
               </div>
                    <span id="defaule_show" style="position:relative;" class="new-input-span mg-b15">
                        营业执照：
                        <input type="file" class="file_upload" name="member_bizlicense" id="member_bizlicense" />
                      <img id="bizlicense"  src="<?php /*echo TEMPLATES_PATH;*/?>/images/zhizhao.png" />
                    </span>-->
                    <span class="new-input-span" style="margin:15px 0;">
                        <input type="checkbox" value="1" name="agree" id="agree" checked style="width:26px; height:26px; display:inline-block">&nbsp;&nbsp;
                        <a href="#!agreement" style="display:inline-block; text-decoration:underline; color:#F00">阅读并同意服务协议 >>></a>
                    </span>
                    <input type="submit" value="注册" class="submit_style" />
                </form>
            </div>
            <a href="index.php?act=register" class="reg_link">邀请码注册</a>
        </div>
        </div>
	</div>
    
    <!--用户服务协议-->
    <div id="agreement" style="margin-bottom: 20px;-webkit-box-flex: 1;width: 100%; overflow:hidden;display: none!important; padding:5px;">
    	<h3 style="text-align:center;"><?php echo $output['doc']['doc_title']?></h3>
        <?php echo $output['doc']['doc_content']?>
    </div>	               
</div>
<script type="text/javascript">
    //获取隐藏表单的值，用什么注册类型就返回true
    function regType(regName){
        var typeVal = $('#mv_type').val();
        if(typeVal==regName){
            return true;
        }else{
            return false;
        }
    }
/*手机验证*/
function sendMobileCode() {
    var countdown;
    if( !((/^1[3|5|7|8][0-9]\d{4,8}$/).test($('#mobile').val()))){alert('请输入正确的手机号码');return false;}
    var count = 120;
    function CountDown() {
        $("#dyMobileButton").attr("disabled", true);
        $("#dyMobileButton").val( count + " 秒后获取");
        if (count == 0) {
            $("#dyMobileButton").val("获取短信验证码").removeAttr("disabled");
            clearInterval(countdown);
        }
        count--;
    }
    $.getJSON('index.php?act=register&op=ajax_get_code_reg_mobile',{mobile:$('#mobile').val(),captcha:$('#captcha').val()},function (data){
        if(data.state==false){
            alert(data.msg);
        }else{
            countdown = setInterval(CountDown, 1000);
        }
    });
}/*手机验证*/
$(function(){
    //注册切换事件S
    $('#invite_member_no').hide();
    $('#invite_no').bind('click',function(){
        $('#invite_member').hide();
        $('#invite_member_no').show();
        //同时将隐藏域mv_type的value改为身份证
        $('#mv_type').val('identify_card');
        $('input[name="invite_name"]').val('');
    });
    $('#invite_yes').bind('click',function(){
        $('#invite_member_no').hide();
        $('#invite_member').show();
        $('#mv_type').val('invite_name');
    });//E

	var area_select = $("#province_id");
	areaInit(area_select,0);//初始化地区
	// 选择地区
	$("#province_id").change(provinceChange);
	function provinceChange(){
	   // 删除后面的select
	   $(this).nextAll().remove();
	   if (this.value > 0){
			var text = $(this).get(0).options[$(this).get(0).selectedIndex].text;
			var area_id = this.value;
			var EP = new Array();
			EP[1]= true;EP[2]= true;EP[9]= true;EP[22]= true;EP[34]= true;EP[35]= true;
			if(typeof(nc_a[area_id]) != 'undefined'){//数组存在
				var areas = new Array();
				var option = "";
				areas = nc_a[area_id];
			//if (typeof(EP[area_id]) == 'undefined'){
				option = "<option value=''>-请选择-</option>";
			//}
			$("<select name='city_id' id='city_id' class=\"{required:true,messages:{required:'请选择城市'}}\">"+option+"</select>").insertAfter(this);
				for (i = 0; i <areas.length; i++){
					$(this).next("select").append("<option value='" + areas[i][0] + "'>" + areas[i][1] + "</option>");
				}
			}
	   }	 	
	}
	$('#city_id').live('change', function() {
        // 删除后面的select
        $(this).nextAll("select").remove();
        if (this.value > 0){
            var text = $(this).get(0).options[$(this).get(0).selectedIndex].text;
            var area_id = this.value;
            var EP = new Array();
            EP[1]= true;EP[2]= true;EP[9]= true;EP[22]= true;EP[34]= true;EP[35]= true;
            if(typeof(nc_a[area_id]) != 'undefined'){//数组存在
                var areas = new Array();
                var option = "";
                areas = nc_a[area_id];
                if (typeof(EP[area_id]) == 'undefined'){
                    option = "<option value=''>-请选择-</option>";
                }
                $("<select name='area_id' id='area_id' class=\"{required:true,messages:{required:'请选择地区'}}\">"+option+"</select>").insertAfter(this);
                for (i = 0; i <areas.length; i++){
                    $(this).next("select").append("<option value='" + areas[i][0] + "'>" + areas[i][1] + "</option>");
                }
            }
        }
    });
    jQuery.validator.addMethod("mob_rul", function(value, element) {
        return this.optional(element) || /(^1[3578]\d{5}$)|(^1[3578]\d{9}$)/.test(value);
    });
    //用户名为数字，下划线，字母，汉子，其他通不过。添加用验证用户名的方法
    jQuery.validator.addMethod("regName_v", function(value, element) {
        return this.optional(element) || /^[\u4E00-\u9FA5\w]{3,20}$/.test(value);
    });
    jQuery.validator.addMethod("pwd_v", function(value, element) {
        return this.optional(element) || /^\w{6,20}$/.test(value);
    });
    //邀请会员和用户名是一样的验证规则
    jQuery.validator.addMethod("invite_v", function(value, element) {
        return this.optional(element) || /^[\u4E00-\u9FA5\w_]{3,20}$/.test(value);
    });
    //验证姓名的正则
    /*jQuery.validator.addMethod("username_v", function(value, element) {
        return this.optional(element) || /^[\u4E00-\u9FA5\w]{2,15}$/.test(value);
    });
    jQuery.validator.addMethod("companyaddr_v", function(value, element) {
        return this.optional(element) || /^[\u4E00-\u9FA5\w\s\,\、\，\.\;\；]{4,100}$/.test(value);
    });*/
	
	$("#login_form ").validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('span');
            error_td.append(error);
        },
		rules: {
			regName: {
                required	: true,
                regName_v   :true,
				remote   : {
                    url : 'index.php?act=register&op=checkName',
                    type: 'get',
                    data:{
                        user_name : function(){
                            return $('#regName').val();
                        }
                    }
                }
            },
			pwd : {
				required	:	true,
                pwd_v       :true
			},
			pwdRepeat : {
				required	:	true,
				equalTo	:	'#pwd'
			},
			mobile: {
                required	: true,
				mob_rul 	: true,
				remote   : {
                    url : 'index.php?act=register&op=checkMobile',
                    type: 'get',
                    data:{
                        mobile : function(){
                            return $('#mobile').val();
                        }
                    }
                }
            },
			mobileCode:{
				required: true,
				 remote   : {
                    url : 'index.php?act=register&op=ajax_check_mobcode',
                    type: 'get',
                    data:{
                        mobileCode : function(){
                            return $('#mobileCode').val();
                        },captcha : function(){
                            return $('#captcha').val();
                        }
                    }
                }
			},
            invite_name:{
                required: function(){
                    return regType('invite_name');
                },
                invite_v:true,
                remote   : {
                    url : 'index.php?act=register&op=checkInviteName',
                    type: 'get',
                    data:{
                        invite_name : function(){
                            return $('#invite_name').val();
                        }
                    }
                }
            },
            //如果显示时才验证,隐藏不用验证
            member_idcard:{
                required: function(){
                    return regType('identify_card');
                }
            },
            member_idcard_r:{
                required: function(){
                    return regType('identify_card');
                }
            },
            member_inside_photo:{
                required: function(){
                    return regType('identify_card');
                }
            },
            <?php if(true||C('captcha_status_register') == '1') { ?>
            captcha : {
                required : true,
                remote   : {
                    url : 'index.php?act=seccode&op=check&nchash=<?php echo $output['nchash'];?>',
                    type: 'get',
                    data:{
                        captcha : function(){
                            return $('#captcha').val();
                        }
                    }
                }
            },
            <?php } ?>
            agree : {
                required	:	true
            }
			/*username:{
				required: true,
                username_v:true
			},
            companyname:{
                required: true,
                maxlength:50
            },
            companyaddr  :{
                required: true,
                companyaddr_v:true
            },

            member_bizlicense:{
                required: function(){
                    return mv_type('bizlicense');
                }
            },*/

		},
		messages: {
			regName: {
                required	: '用户名不能为空',
                regName_v   : '用户名必须是3-20位汉字，字母，数字，下划线',
				remote   : '用户名已存在'
            },
			pwd : {
				required	:	'密码不能为空',
                pwd_v       :'密码为6~20位的字母，数字，下划线'
			},
			pwdRepeat : {
				required	:	'确认密码不能为空',
				equalTo	:	'确认密码与密码不一致'
			},
			mobile: {
                required	: '手机号码不能为空',
				mob_rul	:	'手机号码输入错误',
				remote   :	'手机号码已存在'
            },
			mobileCode:{
				required: '短信验证码不能为空',
				remote:'短信验证码错误'
			},
            /*invite_name:{
                required: '邀请会员不能为空',
                invite_v:'邀请会员不正确',
                remote: '邀请会员不存在'
            },
            member_idcard:{
                required: '请上传身份证正面照'
            },
            member_idcard_r:{
                required: '请上传身份证反面照'
            },
            member_inside_photo:{
                required: '请上传店内照片'
            },*/
            <?php if(true||C('captcha_status_register') == '1') { ?>
            captcha : {
                required : '验证码不能为空',
                remote   : '验证码输入错误'
            },
            <?php } ?>
            agree : {
                required	:	'请阅读并同意该协议'
            }
			/*username:{
				required: '联系人姓名不能为空',
                username_v:'姓名不合法'
			},
			 companyname:{
				required: '商城名称不能为空',
                maxlength:'商城名称不合法'
			},
			companyaddr  :{
				required: '详细地址不能为空',
                companyaddr_v:'详细地址不正确'
			},

            member_bizlicense:{
                required: '请上传营业执照',
            },*/

		}
	});
});
</script>